package com.work.tz.controller;

import com.alibaba.fastjson.JSON;
import com.work.tz.model.Menu;
import com.work.tz.model.TPerson;
import com.work.tz.service.MenuService;
import com.work.util.ResponseResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("menu")
public class MenuController {

    private static final Logger logger = LoggerFactory.getLogger(MenuController.class);

    @Autowired
    private MenuService menuService;

    @RequestMapping(value = "getMenu",method = RequestMethod.POST)
    public ResponseResult<List<Map<String,Object>>> getMenu2RolePerson(@RequestBody TPerson person){
        logger.info("MenuController 入参" + JSON.toJSONString(person));
        List<Map<String,Object>> list = menuService.getMenu2RolePerson(person);
        logger.info("MenuController 出参" + JSON.toJSONString(list));
        return ResponseResult.OK().setData(list);
    }

    @RequestMapping(value = "getMenu2",method = RequestMethod.POST)
    public ResponseResult<List<Menu>> getMenu2RolePerson2(@RequestBody TPerson person){
        logger.info("MenuController 入参" + JSON.toJSONString(person));
        List<Menu> list = menuService.getMenu2RolePerson2(person);
        return ResponseResult.OK().setData(list);
    }

}
